home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / UTILSTEM / HACKROM.LZH / ROMSPLIT.C < prev    next >
Text File  |  1985-12-31  |  834b  |  36 lines

  1. /* This program is designed to split a file into two files such
  2.    that each of the target files represents streams of bytes from
  3.    alternate locations in the source file.  Used to make hi / lo
  4.    proms for 16 bit systems.  Uses a file called temp as its input
  5.    and produces two files called tempevn and tempodd as its output.
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. main(argc,argv)
  10. {
  11. int c;
  12. FILE *fp1, *fp2, *fp3;
  13. if ((fp1 = fopen("temp","rb")) == NULL)
  14.     {
  15.     perror("Can't open temp");
  16.     exit(0);
  17.     }
  18. fp2 = fopen("tempevn","wb");
  19. fp3 = fopen("tempodd","wb");
  20. while ((c = getc(fp1)) != EOF)
  21.     {
  22.     putc(c, fp2);
  23.     if ((c = getc(fp1)) == EOF)
  24.         {
  25.         fclose(fp2);
  26.         fclose(fp3);
  27.         printf("Warning - odd number of bytes in temp\n");
  28.         exit(0);
  29.         }
  30.     putc(c, fp3);
  31.     }
  32. fclose(fp2);
  33. fclose(fp3);
  34. exit(0);
  35. }    
  36.